package com.box.ai.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.box.ai.pojo.entity.School;
import com.box.ai.mapper.SchoolMapper;
import com.box.ai.service.SchoolService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 校区表(School)表服务实现类
 *
 * @author makejava
 * @since 2025-04-06 13:19:40
 */
@Service("schoolService")
public class SchoolServiceImpl implements SchoolService {
    @Resource
    private SchoolMapper schoolDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public School queryById(Integer id) {
        return this.schoolDao.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param school 实例对象
     * @return 实例对象
     */
    @Override
    public School insert(School school) {
        this.schoolDao.insert(school);
        return school;
    }

    /**
     * 修改数据
     *
     * @param school 实例对象
     * @return 实例对象
     */
    @Override
    public School update(School school) {
        this.schoolDao.update(school);
        return this.queryById(school.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.schoolDao.deleteById(id) > 0;
    }
}
